package org.gl.rtsp;

import java.io.IOException;
import java.io.OutputStream;
/**
 * RTSP 相应信息的封装
 * @author Administrator
 *
 */
public class Response {
	public static String SERVER_NAME = "GeLiang-JLKJ RTSP proxy Server";
	public static final String STATUS_BAD_REQUEST = "400 Bad Request";
	public static final String STATUS_NOT_FOUND = "404 Not Found";
	public static final String STATUS_INTERNAL_SERVER_ERROR = "500 Internal Server Error";
	public static final String STATUS_Method_Not_Allowed = "405 Method Not Allowed";
	
	private static  String ERR = "RTSP/1.0 "+"%s"+"\r\n" +
			"Server: "+SERVER_NAME+"\r\n"+ 
			"\r\n";
	public Response(OutputStream mOutput) {
		// TODO Auto-generated constructor stub
	}
	
	public int status;
	public String status_info;

	public static void returnErr(OutputStream mOutput,String string) {
		String s = String.format(ERR, string);
		System.out.println("==================err=================");
		System.out.println(s);
		byte[] errbyte = s.getBytes();
		try {
			mOutput.write(errbyte, 0, errbyte.length);
			mOutput.flush();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			try {
				mOutput.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		
	}
	public static void returnFakeOK(OutputStream mOutput,String string) {
		String s = String.format(ERR, string);
		System.out.println("==================err=================");
		System.out.println(s);
		byte[] errbyte = s.getBytes();
		try {
			mOutput.write(errbyte, 0, errbyte.length);
			mOutput.flush();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			try {
				mOutput.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		
	}

	public void send(OutputStream mOutput) {
		// TODO Auto-generated method stub
		
	}

	public boolean isStreaming() {
		// TODO Auto-generated method stub
		return false;
	}

}
